#!/usr/bin/env python3

def toNum(num, bit):
    def _toNum(num, bit):
        if num == 0:
            return
        _toNum(num // bit, bit)
        print("0123456789ABCDEF"[num % bit], end='')

    if num == 0:
        print('0')
        return

    if num < 0:
        print('-')
        num *= -1

    print({2: '0b', 8: '0o', 10: '', 16: '0x'}[bit], end='')

    _toNum(num, bit)

    print()


def main():
    toNum(*[int(x) for x in input("请输入数字和进制数: ").split()])

if __name__ == "__main__":
    main()
